#ifndef _MAN_PRTLOG_H_
#define _MAN_PRTLOG_H_

#include "stdio.h"
#include <stdarg.h>
#include <cstring>
#include "lock.h"
#include "common.h"

/* 输出格式定义 */
#define ESC_START     "\033["
#define ESC_END       "\033[0m"
#define ESC_FLICK     "\033[5m"
#define ESC_RECER     "\033[7m"
#define COLOR_FATAL   "31;40;5m"
#define COLOR_ALERT   "31;40;1m"
#define COLOR_CRIT    "31;40;1m"
#define COLOR_ERROR   "31;40;1m"
#define COLOR_WARN    "33;40;1m"
#define COLOR_NOTICE  "34;40;1m"
#define COLOR_INFO    "32;40;1m"
#define COLOR_DEBUG   "36;40;1m"
#define COLOR_TRACE   "37;40;1m"

/*
功能: 打印 log
方法：
	无参构造：Log 输出到终端
	有参构造：Log 输出到文件，append 指是否把 Log 追加到文件末尾
	printf：无锁输出
	printf_lock：有锁输出
*/

using namespace std;

class ManPtrLog {
public:
	ManPtrLog();
	ManPtrLog(const char * name, bool append = true);
	~ManPtrLog();
	int Printf(const char* fmt, ...);
	int Printf_Lock(const char* fmt, ...);

private:
	ManLock m_lock;
	bool m_savefile;
	FILE * m_fp;
};

#endif
